<%--
  Created by IntelliJ IDEA.
  User: User
  Date: 2024/9/9
  Time: 8:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script>
    $(function(){
        $("#spell").keyup(function(){
            $("#d1").empty();
            if($(this).val()==""){
                return;
            }
            $.ajax({
                type:"post",
                url:"${pageContext.request.contextPath}/query",
                data:{"spell":$(this).val()},
                dataType:"json",
                success:function(result){
                    for(var i=0;i<result.length;i++){
                        $("#d1").append($("<p>"+result[i].message+"</p>"))
                    }
                },
                error:function(e){
                    // if(e.status==404){
                    //     console.log("没有找到该页面")
                    // }
                    console.log("请求失败");
                }
            });
        });
    });
</script>
<html>
<head>
    <title>Title</title>
</head>
<body>
    请输入文本:<input type="text" id="spell">
    <div id="d1"></div>
</body>
</html>
